﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.Xml.Schema;
using System.Xml;

namespace AgilePlannerDT.Data.Impl
{
    public class LegendDataObject : Legend
    {
        #region Attributes

        protected string aqua, blue, gray, green, khaki, peach, pink, red, white, yellow;

        #endregion

        #region Constructors

        public LegendDataObject(string aqua, string blue, string gray, string green, string khaki,
            string peach, string pink, string red, string white, string yellow)
        {
            this.aqua = aqua;
            this.blue = blue;
            this.gray = gray;
            this.green = green;
            this.khaki = khaki;
            this.peach = peach;
            this.pink = pink;
            this.red = red;
            this.white = white;
            this.yellow = yellow;
        }

        public LegendDataObject(Legend original)
        {
            this.aqua = original.Aqua;
            this.blue = original.Blue;
            this.gray = original.Gray;
            this.green = original.Green;
            this.khaki = original.Khaki;
            this.peach = original.Peach;
            this.pink = original.Pink;
            this.red = original.Red;
            this.white = original.White;
            this.yellow = original.Yellow;
        }

        public LegendDataObject()
        {

            this.blue = "blue";
            this.red = "red";
            this.green = "green";
            this.yellow = "yellow";
            this.white = "white";
            this.pink = "pink";
            this.aqua = "aqua";
            this.khaki = "khaki";
            this.peach = "peach";
            this.gray = "gray";

        }

        #endregion

        #region Legend Members

        public string Blue
        {
            get { return this.blue; }
            set { this.blue = value; }
        }

        public string Red
        {
            get { return this.red; }
            set { this.red = value; }
        }

        public string Green
        {
            get { return this.green; }
            set { this.green = value; }
        }

        public string Yellow
        {
            get { return this.yellow; }
            set { this.yellow = value; }
        }

        public string White
        {
            get { return this.white; }
            set { this.white = value; }
        }

        public string Pink
        {
            get { return this.pink; }
            set { this.pink = value; }
        }

        public string Aqua
        {
            get { return this.aqua; }
            set { this.aqua = value; }
        }

        public string Khaki
        {
            get { return this.khaki; }
            set { this.khaki = value; }
        }

        public string Peach
        {
            get { return this.peach; }
            set { this.peach = value; }
        }

        public string Gray
        {
            get { return this.gray; }
            set { this.gray = value; }
        }

        #endregion

        #region IXmlSerializable Members

        public XmlSchema GetSchema()
        {
            return null;
        }

        public void ReadXml(XmlReader reader)
        {
            Aqua = reader.GetAttribute("aqua");
            Blue = reader.GetAttribute("blue");
            Gray = reader.GetAttribute("gray");
            Green = reader.GetAttribute("green");
            Khaki = reader.GetAttribute("khaki");
            Peach = reader.GetAttribute("peach");
            Pink = reader.GetAttribute("pink");
            Red = reader.GetAttribute("red");
            White = reader.GetAttribute("white");
            Yellow = reader.GetAttribute("yellow");

        }

        public void WriteXml(XmlWriter writer)
        {
            writer.WriteStartElement("Legend");
            writer.WriteAttributeString("aqua", aqua);
            writer.WriteAttributeString("blue", blue);
            writer.WriteAttributeString("gray", gray);
            writer.WriteAttributeString("green", green);
            writer.WriteAttributeString("khaki", khaki);
            writer.WriteAttributeString("peach", peach);
            writer.WriteAttributeString("pink", pink);
            writer.WriteAttributeString("red", red);
            writer.WriteAttributeString("white", white);
            writer.WriteAttributeString("yellow", yellow);
            writer.WriteEndElement();
        }

        #endregion

        #region Object Members

        public override string ToString()
        {
            return "###################################\n" + "#             Legend              #\n"
                + "###################################\n\n" + "Aqua:\t\t" + Aqua + "\n" + "Blue:\t\t" + Blue + "\n"
                + "Gray:\t\t" + Gray + "\n" + "Green:\t\t" + Green + "\n" + "Khaki:\t\t" + Khaki + "\n"
                + "Peach:\t\t" + Peach + "\n" + "Pink:\t\t" + Pink + "\n" + "Red:\t\t" + Red + "\n"
                + "White:\t\t" + White + "\n" + "Yellow:\t\t" + Yellow;
        }

        public override int GetHashCode()
        {
            return (aqua.GetHashCode() + 
                blue.GetHashCode() + 
                gray.GetHashCode() + 
                green.GetHashCode() + 
                khaki.GetHashCode() + 
                peach.GetHashCode() + 
                pink.GetHashCode() + 
                red.GetHashCode() + 
                white.GetHashCode() + 
                yellow.GetHashCode());
        }

        public override bool Equals(object obj)
        {
            if (obj is LegendDataObject)
            {
                LegendDataObject l = (LegendDataObject)obj;

                return (aqua.Equals(l.Aqua) && 
                    blue.Equals(l.Blue) && 
                    gray.Equals(l.Gray) &&
                    green.Equals(l.Green) && 
                    khaki.Equals(l.Khaki) && 
                    peach.Equals(l.Peach) &&
                    pink.Equals(l.Pink) && 
                    red.Equals(l.Red) && 
                    white.Equals(l.White) && 
                    yellow.Equals(l.Yellow));
            }
            return false;
        }

        #endregion

        #region ICloneable Members

        public object Clone()
        {
            return new LegendDataObject(this);
        }

        #endregion
    }
}